import { Name } from "./Name"
import { Contact } from "./Contact"
import { Country } from "./Country";

export class Company {
    name = new Name()
    description = new Name()
    contacts = new Contact()
    licenceNumber = ""
    identificationCode = ""
    addr = new Country()

    constructor(name = new Name(), description = new Name(), contacts = new Contact(), licenceNumber = "", identificationCode = "", addr = new Country()){
        this.name = name
        this.description = description
        this.contacts = contacts
        this.licenceNumber = licenceNumber
        this.identificationCode = identificationCode
        this.addr = addr
    }

    static isValid(obj){
        let valid = true;
        valid &= obj.licenceNumber != undefined
        valid &= obj.identificationCode != undefined

        valid &= obj.name != undefined
        valid &= obj.description != undefined
        valid &= obj.addr != undefined

        if (valid){
            valid &= Name.isValid(obj.name)
            valid &= Name.isValid(obj.description)
            valid &= Country.isValid(obj.addr)
            valid &= Contact.isValid(obj.contacts)
        }

        return valid
    }
}